package edu.cmu.atlub.model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import edu.cmu.atlub.persistence.ConnectionManager;

public class FollowsModel {
    public static void insertIntoFollows(long follower_id, long target_id) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
	Connection conn = ConnectionManager.getConnection();
	insertIntoFollows(follower_id, target_id, conn);
	conn.close();
    }
    
    // follower follows target
    public static void insertIntoFollows(long follower_id, long target_id, Connection conn) throws SQLException {
	String sqlStr = "INSERT IGNORE INTO follows (follows_id, follower_id, target_id) VALUES (NULL, ?, ?);";
	PreparedStatement stmt = conn.prepareStatement(sqlStr);
	stmt.setLong(1, follower_id);
	stmt.setLong(2, target_id);
	stmt.executeUpdate();
    }
}
